package com.itheima.controller;


import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.constant.MessageConstant;
import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;
import com.itheima.entity.Result;
import com.itheima.pojo.Order;
import com.itheima.pojo.OrderSettingList;
import com.itheima.service.OrderService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/order")
@RestController
public class OrderSettingListController {
    @Reference
    OrderService orderService;

    @RequestMapping("/addByPhone.do")
    public Result addByPhone(@RequestBody OrderSettingList orderSettingList) {


        orderSettingList.setOrderType(Order.ORDERTYPE_TELEPHONE);
        try {
            orderService.addByPhone(orderSettingList);
            return new Result(true, MessageConstant.ADD_ORDERSETTINGLIST_SUCCESS);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, MessageConstant.ADD_ORDERSETTINGLIST_FAIL);
        }
    }
    @RequestMapping("/findPage")
    public PageResult findPage(@RequestBody QueryPageBean queryPageBean) {
        return orderService.findPage(queryPageBean);
    }
}
